home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SPACE 2
/
SPACE - Library 2 - Volume 1.iso
/
apps
/
102
/
examples
/
extimdat.c
< prev
next >
Wrap
C/C++ Source or Header
|
1987-01-25
|
3KB
|
97 lines
#include <stdio.h>
#include <osbind.h>
#include <types.h>
extern char *ctime();
/* IKB and GEMDOS TIME-date display demo- ST-SHOPPER Dec'86 W.Rostek */
/* exhibit as printed before corrections necessary to make MWC pretty */
/* The array is filled as follows: year,month,day,hours,minutes,seconds */
/* FUNCTION: [0] , [1] , [2] , [3] , [4] , [5] */
timex(t,s) long t;
int s[6];
{
long raw;
long mask;
int temp;
raw = t;
mask = 0x1f;
temp = (int) (raw & mask);
s[5] = 2 * temp;
raw = t >> 5 ;
mask = 0x3f;
temp = (int) (raw & mask);
s[4] = temp;
raw = t >> 11 ;
mask = 0x1f;
temp = (int) (raw & mask);
s[3] = temp;
raw = t >> 16 ;
mask = 0x1f;
temp = (int) (raw & mask);
s[2] = temp;
raw = t >> 21 ;
mask = 0xf;
temp = (int) (raw & mask);
s[1] = temp;
raw = t >> 25 ;
mask = 0x7f;
temp = (int) (raw & mask);
temp += 80;
s[0] = temp;
}
/* FUNCTION */
shotime(s) int s[6];
{
printf("The date is : %02d/%02d/%02d\n",s[1],s[2],s[0]);
printf("The time is : %02d:%02d:%02d\n",s[3],s[4],s[5]);
}
/* exctime.c EXHIBIT / * from MWC * /
#include <types.h>
main()
{
extern char *ctime();
time_t t;
time(&t);
printf(ctime(&t));
} */
main()
{
long timedate;
int td[6];
long temp;
int t1;
long t2;
long old;
time_t t;
time(&t);
printf(ctime(&t));
printf("The system time and Date:\n");
timedate = Gettime();
old = timedate ;
timex( timedate,td );
shotime(td);
printf("\n The GEMDOS time and date:\n");
t1 = Tgetdate();
temp = (long) t1;
temp = temp << 16 ;
temp &= 0xffff0000L;
t1 = Tgettime();
t2 = (long) t1;
t2 &= 0x0000ffffL;
temp += t2;
timex(temp,td);
shotime(td);
printf("\n EXTIMDAT.* Demonstration.Touch any Key to Continue:\n");
Bconin(2); /* for readable pause - omit if really quick! */
}